package com.hyacinth.cloudnote.modules.note.repository;

import com.hyacinth.cloudnote.modules.note.model.Note;
import com.hyacinth.cloudnote.modules.note.model.NoteBook;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

/**
 * Note实体类对应的基础业务Repository
 */
@org.springframework.stereotype.Repository
public interface NoteRepository extends Repository<Note, UUID>, QuerydslPredicateExecutor<Note> {

    Note save(Note model);

    Optional<Note> findById(UUID id);

    Page<Note> findAll(Pageable pageable);

    void delete(Note note);

    void deleteAllByNoteBook(NoteBook noteBook);

    List<Note> findByNoteBook(NoteBook noteBook);
}
